📜 [專欄新文章] Gas Efficient Card Drawing in Solidity
✍️ Ping Chen
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Assign random numbers as the index of newly minted NFTs
Scenario
The fun of generative art NFT projects depends on randomness. The industry standard is “blind box”, where both the images’ serial number and the NFTs’ index are predetermined but will be shifted randomly when the selling period ends. (They call it “reveal”) This approach effectively solves the randomness issue. However, it also requires buyers to wait until the campaign terminates. What if buyers want to know the exact card right away? We’ll need a reliable onchain card drawing solution.
The creator of Astrogator🐊 isn’t a fan of blind boxes; instead, it thinks unpacking cards right after purchase is more interesting.
Spec
When initializing this NFT contract, the creator will determine the total supply of it. And there will be an iterable function that is randomly picking a number from the remaining pool. The number must be in range and must not collide with any existing ones.
Our top priority is accessibility/gas efficiency. Given that gas cost on Ethereum is damn high nowadays, we need an elegant algorithm to control gas expanse at an acceptable range.
Achieving robust randomness isn’t the primary goal here. We assume there’s no strong financial incentive to cheat, so the RNG isn’t specified. Implementers can bring their own source of randomness that they think is good enough.
Implementation
Overview
The implementation is pretty short and straightforward. Imagine there’s an array that contains all remaining(unsold) cards. When drawIndex() is called, it generates a (uniform) random seed to draw a card from the array, shortens the array, and returns the selected card.
Algorithm
Drawing X cards from a deck with the same X amount of cards is equal to shuffling the deck and dealing them sequentially. It’s not a surprise that our algorithm is similar to random shuffling, and the only difference is turning that classic algo into an interactive version.
A typical random shuffle looks like this: for an array with N elements, you randomly pick a number i in (0,N), swap array[0] and array[i], then choose another number i in (1,N), swap array[1] and array[i], and so on. Eventually, you’ll get a mathematically random array in O(N) time.
So, the concept of our random card dealing is the same. When a user mints a new card, the smart contract picks a number in the array as NFT index, then grabs a number from the tail to fill the vacancy, in order to keep the array continuous.
Tweak
Furthermore, as long as the space of the NFT index is known, we don’t need to declare/initialize an array(which is super gas-intensive). Instead, assume there’s such an array that the n-th element is n, we don’t actually initialize it (so it is an array only contains “0”) until the rule is broken.
For the convenience of explanation, let’s call that mapping cache. If cache[i] is empty, it should be interpreted as i instead of 0. On the other hand, when a number is chosen and used, we’ll need to fill it up with another unused number. An intuitive method is to pick a number from the end of the array, since the length of the array is going to decrease by 1.
By doing so, the gas cost in the worst-case scenario is bound to be constant.
Performance and limitation
Comparing with the normal ascending index NFT minting, our random NFT implementation requires two extra SSTORE and one extra SLOAD, which cost 12600 ~ 27600 (5000+20000+2600) excess gas per token minted.
Theoretically, any instantly generated onchain random number is vulnerable. We can restrict contract interaction to mitigate risk. The mitigation is far from perfect, but it is the tradeoff that we have to accept.
ping.eth
Gas Efficient Card Drawing in Solidity was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有173部Youtube影片,追蹤數超過2,030的網紅數位時代Official,也在其Youtube影片中提到,公司簡介 智慧貼紙股份有限公司(Smart Tag Inc.)正式成立於2020年3月,由創辦人/CEO張焜傑與其他四位共同創辦人一同經營,為各行業提供工業4.0無痛升級方案– Smart Tag解決方案,包含軟硬體技術。由軟性電路板黏貼至機器表面,進行多點位資料蒐集,例如:震動、溫度以及濕度等紀錄...
「high cost」的推薦目錄:
high cost 在 IELTS Nguyễn Huyền Facebook 的精選貼文
TỪ VỰNG CHỦ ĐỀ MONEY {kèm các THÀNH NGỮ, COLLOCATION rất hay}
🍄PHẦN THÀNH NGỮ
- money doesn’t grow on trees = said to warn someone to be careful how much money they spend, because there is only a limited amount: tiền không mọc từ trên cây → không nên tiêu pha quá nhiều tiền, vì tiền chỉ có hạn
- bread and butter = a job or activity that provides you with the money you need to live: kế sinh nhai, công việc giúp bạn trang trải cuộc sống
- bring home the bacon = supply material provision or support; earn a living: kiếm tiền về nuôi sống gia đình
- born with a silver spoon in your mouth = born into a very wealthy family: sinh ra đã ngậm thìa bạc → được sinh ra trong 1 gia đình giàu có
- a penny saved is a penny earned = is a way of saying that one should not waste money but should save it, even if little by little: một xu tiết kiệm cũng chính là một xu làm ra, không nên tiêu xài hoang phí
- an arm and a leg = a lot of money: đắt đỏ
- break the bank = cost too much: rất đắt, rất tốn kém
- easy money = money that is easily and sometimes dishonestly earned: tiền dễ kiếm, bạn không cần tốn quá nhiều công sức để kiếm
- foot the bill = to pay for something, esp. something expensive: chi trả ...
- on the breadline = very poor; with very little money to live on: cuộc sống rất khó khăn, nghèo khổ
- pay your (own) way = pay for everything yourself without relying on others: tự chi trả
🍄PHẦN TỪ VỰNG CHUNG
- to save for the future: tiết kiệm cho tương lai
- to save for retirement: tiết kiệm cho việc nghỉ hưu
- to get out of debt: thoát khỏi nợ nần
- a solid credit score: điểm tín dụng tốt
- long-term financial goals: mục tiêu tài chính dài hạn
- to take control of your finances: kiểm soát tài chính của bạn
- financial success: thành công tài chính
- long-term savings: tiết kiệm dài hạn
- to overspend: chi tiêu quá mức
- to set up a budget: lập ngân sách
- to make adjustments where necessary: thực hiện các điều chỉnh khi cần thiết
- your net income after taxes: thu nhập ròng của bạn sau thuế
- to pay off debt: trả nợ
- a huge financial burden: một gánh nặng tài chính lớn
- to become financially independent: trở nên độc lập về tài chính
- an emergency fund: quỹ cho các trường hợp khẩn cấp
- to cut your monthly expenses: cắt giảm chi phí hàng tháng của bạn
- high-interest credit card debt: nợ thẻ tín dụng lãi suất cao
- to make ends meet: kiếm sống, xoay sở cho đủ sống
- student loans: khoản vay cho sinh viên
👉PHẦN VÍ DỤ: Page mình xem tại đây nhé https://ielts-nguyenhuyen.com/tu-vung-chu-de-money/
Chúc page mình học tốt nè <3
#ieltsnguyenhuyen
high cost 在 IELTS Nguyễn Huyền Facebook 的最佳解答
TỪ VỰNG IELTS - HAVING CHILDREN LATER IN LIFE [Kèm ví dụ]
- miscarriage/ complications: sẩy thai/ biến chứng (trong thời kỳ thai sản)
- to experience health problems during pregnancy: gặp các vấn đề sức khỏe khi mang thai
- to be difficult to conceive/ become pregnancy: khó thụ thai / mang thai
- to delay parenthood until…: trì hoãn việc làm cha mẹ cho đến khi …
- to reach higher education levels: đạt trình độ học vấn cao hơn
- improved methods of contraception: các phương pháp tránh thai được cải tiến
- lack of childcare: thiếu dịch vụ chăm sóc trẻ em
- economic & housing uncertainty: sự không ổn định về kinh tế và chỗ ở
- to go through pregnancy later in life: mang thai trễ
- a baby with Down syndrome: em bé mắc Hội chứng Down
- maternal age: độ tuổi sinh sản
- to prioritise education and career: ưu tiên giáo dục và nghề nghiệp
- life’s milestones: các cột mốc của cuộc đời
- to be financially stable/ secure: ổn định / an toàn về tài chính
- to be less stressed about income: bớt căng thẳng về thu nhập
- to pursue advanced degrees: theo đuổi các bằng cấp cao
- to have a healthy baby: sinh được một em bé khỏe mạnh
- chances of fertility: cơ hội sinh sản
- to give birth to a child with genetic disorder: sinh ra một đứa trẻ bị rối loạn di truyền
- to freeze their eggs before the age of 35: đông lạnh trứng của họ trước 35 tuổi
- at an older age: lớn tuổi
- to climb the career ladder / climb the corporate ladder: leo lên nấc thang sự nghiệp
- the availability of contraceptives: sự sẵn có của các biện pháp tránh thai
- to be financially ready to raise children: sẵn sàng về tài chính để nuôi con
- the high cost of raising a child: chi phí cao để nuôi dạy một đứa trẻ
PHẦN VÍ DỤ: https://ielts-nguyenhuyen.com/tu-vung-ielts-having-children-later-in-life/
#ieltsnguyenhuyen
high cost 在 數位時代Official Youtube 的精選貼文
公司簡介
智慧貼紙股份有限公司(Smart Tag Inc.)正式成立於2020年3月,由創辦人/CEO張焜傑與其他四位共同創辦人一同經營,為各行業提供工業4.0無痛升級方案– Smart Tag解決方案,包含軟硬體技術。由軟性電路板黏貼至機器表面,進行多點位資料蒐集,例如:震動、溫度以及濕度等紀錄,再串接至客戶端系統或者上傳雲端數據中心,藉由機器學習及數據模型進行分析,預測機器的運作模式,將由智慧貼紙解決工廠產能及良率的問題。
Smart Tag helps clients to upgrade their manufacturing lines, or machines immediately with minimum learning cost and high ROI. We’re providing a total solution for the manufacturing industry, which includes both hardware product and software as a service. For the hardware part, Smart Tag is our core technology- thermal thin film PCB, the most flexible PCB ever. The main purpose of this Smart Tag is monitoring, collecting and uploading data onto our cloud platform- the machine learning platform via Bluetooth gateway..
With this machine learning mechanism, when continuing monitoring the vibration, this platform can easily predict and detect the “danger zone”, which means the timing that the machine/production line needs to be maintained or be fixed. Or, companies can also forecast the quality of the products, based on these dataset.
公司網站
http://www.smarttag.tech/
high cost 在 還不過來Come.188 Youtube 的最佳解答
The cost is not high, it is easy to make and delicious, and a lot of snacks that can really make money, but...I’ll watch the movie, ha
* Another cold method (milk sorbet): https://youtu.be/6ML9VKMJBps
*Click the text [cc] in the upper right corner of the video and the three dots in the upper right corner, and then click Translate, you can enable subtitles
Facebook:https://www.facebook.com/come.188
Instagram:https://www.instagram.com/come.188/
--------------------------
**Material
Sugar 50g
Salt to taste
Corn flour 50g
Cheese 2 slices
500g whole milk
------------
Outer skin:
100 grams all-purpose flour
30 grams of sugar
130 grams of water
90 grams of bread flour
-------------------------
**Recipe
Sugar 50g
Salt as needed
Corn flour 50g
Cheese 2 slices
whole milk 500g
-------Outer skin--------
Outer skin:
all-purpose flour 100g
sugar 30g
water 130g
bread flour 90g
------------------------
0:00 Fried fresh milk
0:14 Making fried fresh milk ingredients
1:57 Prepare the skin
2:54 Super delicious fried milk
-----------------------
Easy cooking series:
https://youtube.com/playlist?list=PLFThU8PKal0YKLOgeuvZ90Ax8FUVTYXjP
Gourmet snack series:
https://youtube.com/playlist?list=PLFThU8PKal0Ycx1WvL4CYS1VbDnxFUiGg
*Translation:
1. Fried fresh milk
2.Fried milk
3튀긴 우유
4. Yang げミルク
5.तला हुआ दूध
6حليب مقلي
7¹ء·ح´
8.Sữa chiên
9.frixum lac
#fried milk #ASMR #ASMRCOOK
high cost 在 山水畫家的藝術Taiwan Artist World Youtube 的最讚貼文
#航拍 #空拍 #台南
這個「井仔腳瓦盤鹽田」是台南北門的第一座鹽田,也是現存最古老的瓦盤式鹽田遺址,1818年遷此至今,呈現出有如馬賽克拼貼般的地景藝術,不過後來因人工成本過高,於2002年結束。爾後為延續鹽業文化而將此鹽場復育,現已成為台南濱海最具人文特色的景點之一。
This "Jingzaijiao Tile Pan Salt Field" is the first salt pan in Tainan's North Gate, and it is also the oldest surviving tile pan salt pan site. The labor cost was too high and ended in 2002. Later, in order to continue the salt industry culture, the salt farm was restored, and it has become one of the most culturally characteristic scenic spots in Tainan Binhai.
►►►歡迎訂閱梁震明頻道:https://bit.ly/33R0bmf
►►►梁震明臉書粉絲頁:https://www.facebook.com/inkliang/
►►►梁震明痞客邦:http://tom20030208.pixnet.net/blog
►►►梁震明IG:https://www.instagram.com/liang_chenming_art/
【梁震明簡歷】
國立台北藝術大學美術創作研究所畢業。
曾任國立台南藝術大學藝術史系及東海大學美術學系講師。
個展12次,國內外聯展30餘次。
作品曾在香港蘇富比、羅芙奧及沐春堂拍賣成交。
著作「墨色的真相」與「台灣寺廟龍柱造型之研究」獲國立編譯館出版刊行。
現為羲之堂代理之專職水墨畫家。
「山水畫家的藝術」頻道推薦播放清單:
梁震明水墨作品賞析:https://youtube.com/playlist?list=PL5EQF72_a8UD9nXm38PQcabEIbffxyp-h
梁震明水墨創作介紹:https://youtube.com/playlist?list=PL5EQF72_a8UATfktfF0G6o3zCLipJvc-n
水墨藝術材料介紹:https://youtube.com/playlist?list=PL5EQF72_a8UDs1alttOymTOkXl3IhRW04
紓壓療癒輕音樂空拍影片:https://youtube.com/playlist?list=PL5EQF72_a8UCrrHknKxWuwRy8UIh6EnUQ
台灣海景空拍影片分享:https://youtube.com/playlist?list=PL5EQF72_a8UD471Ieo4YaalS5yvbDAIyu
4K畫質空拍影片分享:https://youtube.com/playlist?list=PL5EQF72_a8UD72YQD4vgRR9NaI-brI-4Q
桃園青埔特區記錄:https://youtube.com/playlist?list=PL5EQF72_a8UBSI3tWDXsgQUuzgKzRSGxY
新北景點空拍:https://youtube.com/playlist?list=PL5EQF72_a8UAfbQybqr__G4cLGrtVugsl
桃園景點空拍:https://youtube.com/playlist?list=PL5EQF72_a8UBweKa4jfWGZW39J9ASipD7
新竹景點空拍:https://youtube.com/playlist?list=PL5EQF72_a8UAk7e3AvAuU6IWQsbvn49e6
宜蘭景點空拍:https://youtube.com/playlist?list=PL5EQF72_a8UCnNCun9gC5UM3In0ztXDG_
#DJI #dronefootage #dronevideo #dronephotography #dronestagram #drones #fpv #djiglobal #photography #pro #aerialphotography #dronepilot #travel #nature #dronefly #fpvfreestyle #quadcopter #dronevideo
high cost 在 「這價錢也太貴了吧!」,英文可不能用expensive修飾price 的相關結果
標籤: price, costly, high-priced, high-cost, inflated, steep, low-price, low-cost, inexpensive, 價格高低. ... <看更多>
high cost 在 high cost - 英中– Linguee词典 的相關結果
大量翻译例句关于"high cost" – 英中词典以及8百万条中文译文例句搜索。 ... <看更多>
high cost 在 HIGH-COST在劍橋英語詞典中的解釋及翻譯 的相關結果
high -cost的意思、解釋及翻譯:expensive: 。了解更多。 ... <看更多>